<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - 文件界面</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="/static/hAdmin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/hAdmin/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/static/hAdmin/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="/static/hAdmin/css/animate.css" rel="stylesheet">
    <!--<link href="/static/hAdmin/css/style.css?v=4.1.0" rel="stylesheet">-->
    <link href="/static/hAdmin/css/style3.css?v=4.0" rel="stylesheet">
    <!-- Sweet Alert -->
    <link href="/static/hAdmin/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .addList {
            padding: 10px 30px 10px 30px;
            height: 90px;
            margin-top: 3px;
        }
    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="col-md-11 form-inline" style="margin-bottom: 20px">
        <div class="input-group">
            <input type="text" placeholder="根据文件名进行匹配" id="searchKey"
                   class="input-sm form-control"> <span
                class="input-group-btn">
        </span>   </div>
<!--        <div class="input-group">-->
<!--            <select class="form-control" id="status" value="3">-->
<!--                <option value="" class="form-control">全部</option>-->
<!--                <option value="1" class="form-control">正常</option>-->
<!--                <option value="2" class="form-control">审核未通过</option>-->

<!--            </select>-->

<!--        </div>-->
        <div class="input-group">
            <button type="button" class="btn btn-sm btn-primary"
                    id="getByKeywords">搜索</button>
        </div>
    </div>
    <div class="row">
        <span id="gloUrl" style="display: none"></span>
        <div id="row">

        </div>
        <!--                        页码控制-->
        <div id="pageHelper" ajaxUrl="www.baidu.com" currentPage="1">
            <div class="pageBottom col-xs-10 col-xs-offset-1" style="margin-top: 20px">
                <nav aria-label="...">
                    <ul class="pager">
                        <li class="previous disabled"><a href="javascript:void(0)"><span
                                aria-hidden="true">&larr;</span>
                            Older</a></li>
                        <li>
                            <span>共</span>
                            <span id="data_total">${total}</span>
                            <span>条数据</span>
                        </li>
                        <li class="next"><a href="javascript:void(0)">Newer <span
                                aria-hidden="true">&rarr;</span></a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="/static/hAdmin/js/jquery.min.js?v=2.1.4"></script>
<script src="/static/hAdmin/js/bootstrap.min.js?v=3.3.6"></script>

<!-- Sweet alert -->
<script src="/static/hAdmin/js/plugins/sweetalert/sweetalert.min.js"></script>
<!-- 自定义js -->
<script src="/static/hAdmin/js/content.js?v=1.0.0"></script>
<script src="/static/js/GloJs.js"></script>
<!-- Toastr script -->
<script src="/static/hAdmin/js/plugins/toastr/toastr.min.js"></script>
<script>

    $(document).ready(function () {
        $('.contact-box').each(function () {
            animationHover(this, 'pulse');
        });
    });

    $(function () {
        let Glo_BaseUrl = $("#gloUrl").attr("gloUValue")
        let Glo_user = localStorage.getItem("userId")
        let currentPage = $("#pageHelper").attr("currentPage");

        let pageSize = 6;//每页条数
        function getList() {
            let searchKey = $("#searchKey").val();
            let total = 0;//总数
            $("#row").html("")
            $.ajax({
                url: Glo_BaseUrl + "/tFile/listcourse",
                type: "get",
                data: {
                    "pageSize": pageSize,
                    "pageNum": currentPage,
                    "fileName": searchKey,

                    "status":$("#status").val()
                },
                success: function (data) {
                    let str = ``
                    for (let i = 0; i < data.list.length; i++) {

                        str += ` <div class="col-sm-4">
      <div class="contact-box" style="height: 240px;">

          <div class="col-sm-4">
            <div class="text-center" style="height: 100px;width: 100px;">
              <img alt="image" style="width: 100%;height: 100%;" title="图片" class="img-circle m-t-xs " src="${data.list[i].image}">
            </div>
          </div>
          <div class="col-sm-8">

            <h3><strong>${data.list[i].fileName}</strong></h3>
             <p>下载次数: <span>${data.list[i].downloadTimes}</span> </p>
            <p>
            所属景点/特色:<span style="color: #579ddc">${data.list[i].title}</span>
            </p>

            <p>上传时间: <span>${data.list[i].createTime}</span> </p>

          </div>
          <div class="clearfix">
              <a href="/tFile/download?id=${data.list[i].id}" title="点击下载文件" class="btn btn-info btn-sm" ><i class="fa fa-download"></i>  </a>
              <button  title="删除" thisId="${data.list[i].id}" class="btn btn-danger btn-sm delFile" ><i class="fa fa-trash"></i>  </button>

</div>

      </div>
    </div>`

                    }

                    $("#row").append(str)




                    total = data.total
                    $("#data_total").html(data.total);
                    //下一页
                    $('.next').unbind().click(function () {
                        if (currentPage * pageSize >= total) {
                            alert('已经是最后一页了')
                        } else {
                            currentPage++;
                            $("#pageHelper").attr("currentPage", currentPage);
                            if (currentPage > 0) {
                                $(".previous").removeClass("disabled")
                            }
                            $(".project-list").addClass("animated bounceOutLeft")
                            setTimeout(function () {
                                $(".project-list").removeClass("animated bounceOutLeft").addClass("animated bounceInRight")
                            }, 500)
                            getList(2)
                        }

                    });
                    //上一页
                    $('.previous').unbind().click(function () {
                        currentPage--;
                        $("#pageHelper").attr("currentPage", currentPage);
                        if (currentPage === 0) {
                            currentPage = 1;
                            $("#pageHelper").attr("currentPage", currentPage);
                            $(".previous").addClass("disabled");
                        } else {
                            $(".project-list").addClass("animated bounceOutRight")
                            setTimeout(function () {
                                $(".project-list").removeClass("animated bounceOutRight bounceInRight").addClass("animated bounceInLeft")
                            }, 500)
                            getList(2)
                        }
                    });
                    $(".delFile").click(function (){
                        let id = $(this).attr("thisId")

                        $.ajax({
                          url: Glo_BaseUrl + "/tFile/del",
                          type: "post",
                          data: {
                            "id":id
                          },
                          success: function (data) {
                              windowsAuto(200,"删除成功")
                              getList()
                          },
                          error: function () {
                            alert("服务器异常！network error！")
                          }
                        })
                    })
                },
                error: function () {
                    alert("服务器异常！network error！")
                }
            })
        }

        getList();
        $("#getByKeywords").click(function (){
            getList();
        })


    })

</script>


</body>

</html>
